/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package com.model.service;

import com.model.domain.proceso.envio.subida.LogXmlTransferido;
import com.model.domain.proceso.envio.subida.LogXmlTransferidoError;
import java.sql.Connection;
import java.sql.PreparedStatement;
import util.file.Archivo;

/**
 * @author Rdelacruz
 */
public class LogXmlTransferidoErrorService 
extends AbstractService
{   
    
  public void save(Connection con, LogXmlTransferidoError logxmlerror) throws Exception {
        PreparedStatement ps_error = null;//archivo XML error
        try {
            String sql_error = "insert into Envios_logxmltransferidos_error"
                    + "(fechaerror, usuario, modoenvio, nombrexmldata, tamanho, error) "
                    + "values (GETDATE(),?,?,?,?,?)";
            ps_error = con.prepareStatement(sql_error);
            
            LogXmlTransferido logxml = logxmlerror.getLogXmlTransferido();
            
            Archivo a = logxml.getOperacionSubida().getArchivo();
            
            ps_error.setString(1, (logxml!=null ? logxml.getUsuario() : null) );
            
            ps_error.setString(2, "WEB");
            
            ps_error.setString(3, a!=null ? a.getNombre() : null);
            ps_error.setLong(4, a!=null ? a.getTamanho() : null);
            
            ps_error.setString(5, logxmlerror.getError());

            ps_error.executeUpdate();                     
        }
        finally {
            if(ps_error!=null) ps_error.close();
        }
    }
 
}
